<template> 
  <router-view></router-view>
</template>


<script>

export default ({
  name: 'App',
    created() {
    //解决页面刷新，vuex数据丢失问题
    if (sessionStorage.getItem("store")) {
      this.$store.replaceState(
        Object.assign(
          {},
          this.$store.state,
          JSON.parse(sessionStorage.getItem("store"))
        )
      );
    }
    //在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener("beforeunload", () => {
      sessionStorage.setItem("store", "");
      sessionStorage.setItem("store", JSON.stringify(this.$store.state));
    });
  }

})
</script>

<style scoped>
@import url("assets/global.css");

#app {
  text-align: center;
  color: #2c3e50;
  font-family: Helvetica, Arial, sans-serif;
}



</style>
